package m2acsis.algebre.helpers;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class ToStringHelper {
	
	public static String toString(Object obj, String start, String end){
		
		StringBuffer result = new StringBuffer();
		
		if(obj != null){
			if(obj.getClass().isArray()){
			
				List<Object> objects = new ArrayList<Object>(Arrays.asList((Object[]) obj));
				result.append(start);
	
				
				int size = objects.size();
				for(int i = 0; i < size - 1; i++){
					result.append(toString(objects.get(i), start, end) + ", ");
				}
				
				result.append(toString(objects.get(size -1), start, end));
				result.append(end);
			}
			else{
				result.append(obj.toString());
			}
		}
		
		return result.toString();
	}
}
